<template>
	<view>
		<view class="1">
			<u-search :show-action="true" actionText="搜索" :animation="true"></u-search>
		</view>
		<uni-card v-for="(app,index) in approvelist" :key="index" @click="tomy(app.id)">
			<uni-title type="h3" title='我发起的申请'></uni-title>
			<view class="">
				员工:{{app.ename}}
			</view>
			<view class="">
				部门:{{app.department}}
			</view>
			<view class="">
				提交人:{{app.name}}
			</view>
			<view class="">
				提交时间:{{aa(app.createtime)}}
			</view>
			<view v-show="app.spid==1">
				审批状态： <span style="color: #000000;">等待审批</span>
			</view>
			<view v-show="app.spid==2">
				审批状态：<span style="color:red">审批拒绝请求</span>
			</view>
			<view v-show="app.spid==3">
				审批状态： <span style="color: #18BC37;">审批通过等待抄送</span>
			</view>
			<view v-show="app.spid==4">
				审批状态： <span style="color: #F1A532;">审批通过抄送完成</span>
			</view>
		</uni-card>
		<view class="" style="text-align: center; margin-top: 50rpx;color: #5500ff; margin-bottom: 50rpx;">
			<text>暂时没有更多数据呢~┗|｀O′|┛ 嗷~~</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: {},
				approvelist: {},
			}
		},
		onLoad(res) {
			this.users()
			this.eid = res.eid
			this.selectapprove()
		},
		methods: {
			aa(date) {
				const dateTime = new Date(date)
				const YY = dateTime.getFullYear()
				const MM =
					dateTime.getMonth() + 1 < 10 ? '0' + (dateTime.getMonth() + 1) : dateTime.getMonth() + 1
				const DD =
					dateTime.getDate() < 10 ? '0' + dateTime.getDate() : dateTime.getDate()
				const hh =
					dateTime.getHours() < 10 ? '0' + dateTime.getHours() : dateTime.getHours()
				const mm =
					dateTime.getMinutes() < 10 ? '0' + dateTime.getMinutes() : dateTime.getMinutes()
				const ss =
					dateTime.getSeconds() < 10 ? '0' + dateTime.getSeconds() : dateTime.getSeconds()
				return `${YY}-${MM}-${DD}`
			},
			tomy(id){
				uni.navigateTo({
					url:'./my?id='+id
				})
			},
			users() {
				this.user = uni.getStorageSync('user')
				console.log(this.user)
			},
			selectapprove() {
				uni.request({
					url: 'http://localhost:9525/aduit/approve/mineemp?eid=' + this.eid,
					method: 'GET',
					success: (res) => {
						this.approvelist = res.data.data.list
					},
				});
			}
		}
	}
</script>

<style>

</style>
